import request from '@/utils/request'

enum Api {
  list = '/nvr/loadList',
  save = '/nvr/save',
  edit = '',
  delOne = '/nvr/delete',
  active = '/nvr/activate',
  cameraList = '/camera/loadList',
  cameraEdit = '/camera/update'
}

/**
 * 列表
 * @param data
 */
export const list = async (data: {
  pageNum: number
  pageSize: number
  name: string
  status?: null | string
}) => {
  return await request.post(Api.list, { data })
}

/**
 * 新增/修改
 * @param data
 */
export const save = async (data: {
  id?: undefined | number
  manufacturer?: undefined | string
  name: string
  ip: string
  port: string
  userName: string
  password: string
  remark: string
}) => {
  return await request.post(Api.save, { data })
}

/**
 * 删除
 * @param id
 */
export const delOne = async (params: { id: number }) => {
  return await request.delete(Api.delOne, { params })
}

/**
 * 摄像机列表
 * @param data
 */
export const cameraList = async (data: {
  pageNum: number
  pageSize: number
  name: string
  status?: undefined | string
  type?: undefined | string
}) => {
  return await request.post(Api.cameraList, { data })
}

/**
 * 摄像机修改
 * @param data
 */
export const cameraEdit = async (data: {
  id?: undefined | string
  name: string
  type?: undefined | string
}) => {
  return await request.post(Api.cameraEdit, { data })
}

/**
 * 摄像机激活
 * @param data
 */
export const active = async (data: {
  id?: undefined | number
  ip: string
  port: string
  userName: string
  password: string
  type: undefined | number
}) => {
  return await request.post(Api.active, { data })
}
